﻿using MCPlatform.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace MCPlatform.Views.Shell
{
    /// <summary>
    /// ActivateView.xaml 的交互逻辑
    /// </summary>
    public partial class ActivateView : Window
    {
        public ActivateView()
        {
            InitializeComponent();
           // InitActivateTime();
        }

        public event Action ActivateSuccessEvent;

        ActivationManager activationManager = ActivationManager.GetInstance();


        //private void InitActivateTime()
        //{
        //    int remainingDays = activationManager.CheckActivationStatus();
        //    if (remainingDays == -1)
        //    {
        //        ExpirationDateTextBlock.Text = "未激活或已过期";

        //    }
        //    else if (remainingDays == -999)
        //    {
        //        ExpirationDateTextBlock.Text = "未激活";

        //    }
        //    else
        //    {
        //        ExpirationDateTextBlock.Text = "剩余天数：" + remainingDays;
        //    }
        //}
        //private void ActivateButton_Click(object sender, RoutedEventArgs e)
        //{
        //    string activationCode = ActivationCodeTextBox.Text;
        //    int Ret = activationManager.Activate(activationCode);
        //    if (Ret == -1)
        //    {
        //        ActivationStatusTextBlock.Text = "无效激活码";
        //        return;
        //    }
        //    else if (Ret == 999)
        //    {
        //        ActivationStatusTextBlock.Text = "已经永久，无需激活";
        //        return;
        //    }
        //    else
        //    {
        //        ActivationStatusTextBlock.Text = "激活成功";
        //    }
        //    InitActivateTime();

        //    ActivateSuccessEvent?.Invoke();
        //}

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!activationManager.IsActivated)
            {
                Application.Current?.Shutdown();
            }
        }
    }
}
